
M=2000;
N=1000;

%Get MINIST data
[trainImg trainLab testImg testLab] = getMNISTDigits(M,N);

%display first 40 digits in 4x10 array with their labels
arrangeInGrid(trainImg,trainLab,4,10,70,false);

%compute the prior probability of each digit in the training set
numOccurences=zeros(10,1);

for i=1:M
    label=trainLab(i);
    numOccurences(label+1)=numOccurences(label+1)+1;
end

priorProbabilty=numOccurences/M;

%Generate Latex Table
for i=1:10
    fprintf(1,'%d & %0.3f\\\\\n\\hline\n',...
            i-1,priorProbabilty(i));
end

